<template>
  <header>
    <div class="l-content">
      <img src="../assets/images/logo.png" alt="软件协会" style="width: 60px;">
      <h3>考试系统</h3>
      <div class="l-content-menu">
        <el-menu :default-active="activeIndex" class="el-menu-demo" background-color="#B3C0D1" text-color="#808080"
                 active-text-color="#70A8E1FF" mode="horizontal" @select="handleSelect" router>
          <el-menu-item :index="item.path" v-for="item in menu" :key="item.path">
            <span slot="title">{{ item.label }}</span>
          </el-menu-item>
        </el-menu>
      </div>
    </div>
    <div class="r-content">
      <el-dropdown trigger="click" size="mini">
        <span>
          <img class="user" :src="userImg">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>
            <span @click="toPeopleMessage">个人信息</span>
          </el-dropdown-item>
          <el-dropdown-item>
            <span @click="quitExam">退出</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
export default {
  name: "CommonHeader",
  data() {
    return {
      activeIndex: '1',
      userImg: require('../assets/images/user.jpg'),
      menu: [
        {
          path: '/home',
          name: 'home',
          label: '首页',
        },
        {
          path: '/testMessage',
          name: 'testMessage',
          label: '考试信息'
        },
        {
          path: '/publicPlatform/questionGroup',
          name: 'publicPlatform',
          label: '公共平台',
        }
      ]
    }
  },
  methods: {
    handleSelect() {

    },
    toPeopleMessage(){
      this.$router.replace('/peopleMessage');
    },
    quitExam(){
      //这里返回到登录界面
      this.$router.replace('/')
    }
  }
}
</script>

<style lang="less" scoped>
header{
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  background-color: #B3C0D1;
}
.l-content {
  padding-left: 10px;
  display: flex;
  overflow: hidden;
  align-items: center;
}
.l-content-menu{
  margin-left: 80px;
}
.r-content {
  margin-right: 10px;
  .user {
    margin-top: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}
img{
  width: 30px;
  height: 45px;
}
h3{
  margin-left: 10px;
}
</style>
